package com.abc.robot01.room.dao

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Update
import com.abc.robot01.room.bean.SystemMessageBean

@Dao
interface SystemMessageDao {

    @Insert
    fun insert(systemMessageBean: SystemMessageBean): Long

    @Query("SELECT * FROM System_Message")
    fun queryAll(): List<SystemMessageBean>

    @Query("SELECT * FROM System_Message  WHERE id=:id")
    fun queryById(id:Long): SystemMessageBean

    @Delete
    suspend fun delete(systemMessageBean: SystemMessageBean)

    /**
     */
    @Query("DELETE FROM System_Message WHERE name=:name")
    fun deleteAllAnswerByName(name: String): Int

    /**
     */
    @Query("DELETE FROM System_Message WHERE id=:id")
    fun deleteAllAnswerById(id: Long): Int

    /**
     * 删 where是删除的条件
     * @author Liu.Heng
     */
    @Query("DELETE FROM System_Message")
    fun deleteAll(): Int

    /**
     * 更新
     */
    @Query("UPDATE System_Message SET success = :success where id = :id")
    fun updateSuccess(id: Long,success: Boolean)

    /**
     * 更新
     */
    @Update
    fun update(systemMessageBean: SystemMessageBean)
}
